@layout("/common/_container.html"){
<input type="hidden" id="sortMap" value="">
<input type="hidden" id="reservationsId" value="${reservationsId}">
<input type="hidden" id="customerId" value="${customerId}">
<div class="ibox float-e-margins">
    <div class="ibox-content">
        <div class="form-horizontal" id="addForm">
            <div style="width:100%;">
                <#openRefundM  id="openRefundM" list="${payServiceInfoList}"/>
            </div>
        </div>
        <div class="btnBox" style="margin-top: 20px;">
            <button type="button" class="btn" onclick="returnMonrys()">提交</button>
            <button type="button" class="btn" id="cancel" onclick="addVisitedInfoDlg.close()">取消</button>
        </div>
    </div>

</div>

<link rel="stylesheet" href="${ctxPath}/static/css/jqui/jquery-ui.min.css">
<script src="${ctxPath}/static/js/jquery-ui.min.js"></script>
<script src="${ctxPath}/static/modular/tcCenter/consultant/addVisited_info.js"></script>
<script>
    var getCount = 0;
    function returnMonrys() {
        getCount++;
        if (getCount == 1) {
            var input = document.getElementsByClassName('returnMonry');
            var refund = document.getElementsByClassName('refund');
            var parpams = "";
            var refunds = "";
            for (var f = 0; f < input.length; f++) {
                if(input[f].value == "" || input[f].value == null){
                    alert("请输入正确的退款金额！");
                    getCount = 0;
                    return;
                }else {
                    parpams += parseFloat(input[f].value) + "," + $(".returnMonry").eq(f).attr("id")
                        + "," + refund[f].value + "#";
                }
            }
            var serviceActualPay = document.getElementsByClassName('serviceActualPay');
            for (var i = 0; i < serviceActualPay.length; i++) {
                if (parseFloat(input[i].value) > parseFloat(serviceActualPay[i].innerHTML)) {
                    getCount = 0;
                    alert("不能多于实收金额，请重新输入...！");
                    return;
                }
            }

            $.ajax({
                url: Feng.ctxPath + "/consultant/returnMonrys",
                type: "post",
                data: {
                    "parpams": parpams
                },
                success: function (data) {
                    alert("退款成功!");
                    $('#cancel', parent.document).click();
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
                    window.parent.location.reload();
                },
                error: function (data) {
                    getCount = 0;
                    alert('退款失败!');
                }
            });
        }
    }
</script>

<style>
    .btnBox button {
        background: #30add1;
        color: white;
        width: 96px;
    }
</style>
@}
